//tslint:disable
import { Component, Input, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { CustomAreaComponent } from '../custom-area/custom-area.component';

@Component({
  selector: 'app-open-modal-choose-condition',
  templateUrl: './open-modal-choose-condition.component.html',
  styleUrls: ['./open-modal-choose-condition.component.scss'],
})
export class OpenModalChooseConditionComponent implements OnInit {
  @Input() tagData: any;
  @Input() type: any;
  listData: any;
  constructor(public modalController: ModalController) { }

  ngOnInit() {
    document.getElementById('myreal-box').click();
  }
  go(e, data) {
    // this.modalController.dismiss({ dismissed: true, itemdata: data });
    e.stopPropagation();

  }
  close(e) {
    e.stopPropagation();
    // this.modalController.dismiss({ dismissed: true });
  }

  async onOk1(result, obj) {
    event.stopPropagation();
    if (result[1] && result[1].label === '自定义') {
      const modal = await this.modalController.create({
        showBackdrop: true,
        cssClass: "openmodal-choose-condition",
        component: CustomAreaComponent,
        componentProps: { tagData: obj }
      });
      modal.onDidDismiss().then((data) => {
        const value = data.data;
        if (value !== undefined) {
          if (value.itemdata) {
            this.modalController.dismiss({ dismissed: true, itemdata: { label: value.itemdata.min + '-' + value.itemdata.max + '平米', value: value.itemdata.min + ',' + value.itemdata.max } });
          } else {
            this.modalController.dismiss({ dismissed: true });
          }
        }
      });
      await modal.present();
    } else {
      this.modalController.dismiss({ dismissed: true, itemdata: result[1] });
    }
  }

  onDismiss1() {
    this.modalController.dismiss({ dismissed: true });
  }
}
